<?php
namespace app\home\controller;

use app\BaseController;
use app\home\model\Images;
use app\home\model\Seo;
use think\facade\View;
use app\api\model\Usage;

class ActivePage extends BaseController
{
    public function index()
    {
        $active_page = Images::field(['image', 'image_url'])->where('image_kind', 4)->order('add_time desc')->select();
        $before = [];
        foreach ($active_page as $key => $a_p) {
            if ($key == 0){
                $last = $active_page[$key];
                continue;
            }
            array_push($before, $active_page[$key]);
        }

        View::assign('kw', Seo::getKeywords());
        View::assign('desc', Seo::getDesc());
        View::assign('last_active', $last);
        View::assign('before_active', $before);
        $usage = new Usage;
        $usage->save([
            'access_page'=>'Other',
            'access_time'=>date('Y-m-d', time()),
            'access_ip'=>$_SERVER["REMOTE_ADDR"]
        ]);
        return View::fetch();
    }
}
